<?php
require "../../system/framework.php";

$dataCom=new data();

$com    =$_REQUEST['com'];

//echo "<br><br>";  
echo "com=$com<br>";

$propertyList=array();

//$comList=explode(",", $com);

//for ($n=0; $n < sizeof($comList); $n++)
  //  {
    /*   $sql = $sql."com='{$comList[$n]}'";    
       if ($n < (sizeof($comList)-1))
           $sql = $sql." AND "; */


    //$sql = "SELECT $type FROM _com WHERE "; //"com='{$_REQUEST['com']}'");
//    $sql  = "SELECT id FROM _com WHERE com='{$comList[$n]}'"; //'$com'"
    $sql  = "SELECT id FROM _com WHERE com='{$com}'"; //'$com'"

    $comId=db::getValue($sql);

    if ($comId !== "")
        {


        // _com_property,_property
        //$dataCom->getTable("_com_property", "__com=$comId");
        foreach (data::getTable("_com_property,_property", "__com=$comId") as $dataCom) {
        

        //echo "select * from _com_property where __com=$comId";

        //echo "Anzahl Properties: " . $dataCom->count;

        //if ($dataCom->count > 0)
          //  {
            //do
               // {
                //$property      =db::getValue("SELECT property FROM _property WHERE id={$dataCom['__property']}");
                //echo "<br><br>" . $property . "<br>";
                echo $dataCom['property']."<br>";
                  
                $propertyList[]=$dataCom['property'];

                //echo "com id ".$dataCom->data['__property']."<br>";

                //echo "#editor ".$dataCom->data['com']." {  background-color: green;   }";

                global $rootDir;

                require $rootDir . "/code/property/".strtolower($dataCom['property']).".php";
                //$propertyHtml = file::readTextFile("/code/property/$property.php");
                //echo $propertyHtml;

                } //while ($dataCom->nextRow());
           // }
        }
   // }
?>

<script type = "text/javascript">
    var propertyList = new Array();

    propertyCount = <?php echo sizeof($propertyList);?>;

    <?php for ($n=0; $n<sizeof($propertyList); $n++) {
    
    echo "propertyList[$n] = \"{$propertyList[$n]}\";";
} ?>
</script>